1
|
|
|
import React from "react" |
2
|
|
|
import expectRender from "../expect-to-same-render"; |
3
|
|
|
import type { ClassHash } from "../src/defs"; |
4
|
|
|
import { classNamesMap } from "../src"; |
5
|
|
|
import { Tooltip } from "reactstrap"; |
6
|
|
|
|
7
|
|
|
const classnames = {Root: "App", "Item--active": "hash1"} as Record<"Root"|"Theme--dark"|"Item--active", ClassHash> |
8
|
|
|
, {Root} = classnames |
9
|
|
|
, mapping = classNamesMap(classnames) |
10
|
|
|
|
11
|
|
|
it("Some Component", () => { |
12
|
|
|
type ThirdPartyComponentProps = { |
13
|
|
|
checked?: boolean |
14
|
|
|
ContainerClassName?: string |
15
|
|
|
CheckedClassName?: string |
16
|
|
|
NotCheckedClassName?: string |
17
|
|
|
} |
18
|
|
|
function ThirdPartyComponent({ checked, ContainerClassName, CheckedClassName, NotCheckedClassName}: ThirdPartyComponentProps ) { |
19
|
|
|
return <div className={ContainerClassName}> |
20
|
|
|
<div className={checked ? CheckedClassName : NotCheckedClassName}/> |
21
|
|
|
</div> |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
expectRender( |
25
|
|
|
<ThirdPartyComponent checked={true} {...mapping<ThirdPartyComponentProps>({ |
26
|
|
|
ContainerClassName: {Root, "Theme--dark": true}, |
27
|
|
|
CheckedClassName: {"Item--active": true}, |
28
|
|
|
//@ts-expect-error Object literal may only specify known properties, and 'NotExistentProperty' does not exist |
29
|
|
|
NotExistentProperty: {"Theme--dark": true} |
30
|
|
|
})}/> |
31
|
|
|
).toSame( |
32
|
|
|
<div className="App Theme--dark"> |
33
|
|
|
<div className="hash1"/> |
34
|
|
|
</div> |
35
|
|
|
) |
36
|
|
|
}) |
37
|
|
|
|
38
|
|
|
it("reactstrap Tooltip", () => expectRender( |
39
|
|
|
<Tooltip target="target" {...mapping<typeof Tooltip>({ |
40
|
|
|
className: {Root}, |
41
|
|
|
popperClassName: {"Theme--dark": true}, |
42
|
|
|
innerClassName: {"Item--active": true}, |
43
|
|
|
})}/> |
44
|
|
|
).toSame( |
45
|
|
|
// No static render |
46
|
|
|
)) |
47
|
|
|
|
48
|
|
|
|